package map_;

import com.sun.deploy.cache.BaseLocalApplicationProperties;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

@SuppressWarnings({"all"})
public class MapExercise {
    public static void main(String[] args) {
        Map map = new HashMap();
        Object o1  = map.put(1,new Employee("白","15000","01"));
        Object o2  = map.put(2,new Employee("黑","25000","02"));
        Object o3  = map.put(3,new Employee("青","35000","03"));

        //2.EntrySet获取key-value
        Set entrySet = map.entrySet();
        Iterator iterator = entrySet.iterator();
        while (iterator.hasNext()) {
            Object entry =  iterator.next();
            Map.Entry entry1 = (Map.Entry) entry;
            System.out.println(entry.getClass());
            System.out.println(entry1.getKey() + "----" + entry1.getValue());
        }
    }
}
class Employee{
    private String name;
    private String salary;
    private String id;

    public Employee(String name, String salary, String id) {
        this.name = name;
        this.salary = salary;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSalary() {
        return salary;
    }

    public void setSalary(String salary) {
        this.salary = salary;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", salary='" + salary + '\'' +
                ", id='" + id + '\'' +
                '}';
    }
}